package com.example.shiro.service.base.impl;

import com.example.shiro.mapper.util.MyMapper;
import com.example.shiro.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;
import java.util.List;

/**
 * @Author: lex
 * @Date: 2018/10/13
 */
public class BaseServiceImpl<E> implements BaseService<E> {

    @Autowired
    protected MyMapper<E> baseMapper;

    @Override
    public E selectById(Serializable id) {
        return baseMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<E> selectByExample(Example example) {
        return baseMapper.selectByExample(example);
    }

    @Override
    public List<E> select(E e) {
        return baseMapper.select(e);
    }

    @Override
    public int selectCountByExample(Example example) {
        return baseMapper.selectCountByExample(example);
    }

    @Override
    public int selectCount(E e) {
        return baseMapper.selectCount(e);
    }

    @Override
    public int delete(E e) {
        return baseMapper.delete(e);
    }

    @Override
    public int update(E e) {
        return baseMapper.updateByPrimaryKeySelective(e);
    }

    @Override
    public int add(E e) {
        return baseMapper.insert(e);
    }

    @Override
    public int addList(List<E> list) {
        return baseMapper.insertList(list);
    }

    @Override
    public E query(E m) {
        return baseMapper.selectOne(m);
    }
}
